<?php

if(!defined("INDEX"))
    die;

if(!check_post('login_', 'password_'))
    throw new HackException();

// ----------------------------------------------------------------------------

try {

    $auth = new Auth;

    $remember = obtainHTTPVar('remember', null);

    $user = $auth->loginUser($_POST['login_'], $_POST['password_']);

    $smarty->assign('user', $user);

    // Remember me checkbox case
    if($remember && $user->id > 0) {
        setcookie('auth_hash', $user->cookie, time() + COOKIE_LIFETIME);
    }

} catch (Exception $e) {

    $smarty->assign('errors', array($e->getMessage()));
}

// ---------------------------------------------------------------------------